Don't link wikilinks in section heading autocomments
[lhc/web/wiklou.git] / includes / Linker.php
index 0ecd744..2028197 100644 (file)
@@ -1151,7 +1151,6 @@ class Linker {
                                );
 
                                if ( $comment === null ) {
-                                       $link = '';
                                        if ( $title ) {
                                                $section = $auto;
                                                # Remove links that a user may have manually put in the autosummary
@@ -1160,6 +1159,10 @@ class Linker {
                                                $section = str_replace( '[[', '', $section );
                                                $section = str_replace( ']]', '', $section );
 
+                                               // We don't want any links in the auto text to be linked, but we still
+                                               // want to show any [[ ]]
+                                               $sectionText = str_replace( '[[', '[[', $auto );
+
                                                $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
                                                if ( $local ) {
                                                        $sectionTitle = Title::makeTitleSafe( NS_MAIN, '', $section );
@@ -1168,9 +1171,10 @@ class Linker {
                                                                $title->getDBkey(), $section );
                                                }
                                                if ( $sectionTitle ) {
-                                                       $link = Linker::makeCommentLink( $sectionTitle, $wgLang->getArrow(), $wikiId, 'noclasses' );
-                                               } else {
-                                                       $link = '';
+                                                       $auto = Linker::makeCommentLink(
+                                                               $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
+                                                               $wikiId, 'noclasses'
+                                                       );
                                                }
                                        }
                                        if ( $pre ) {
@@ -1181,10 +1185,11 @@ class Linker {
                                                # autocomment $postsep written summary (/* section */ summary)
                                                $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
                                        }
-                                       $auto = '<span class="autocomment">' . $auto . '</span>';
-                                       $comment = $pre . $link . $wgLang->getDirMark()
-                                               . '<span dir="auto">' . $auto;
-                                       $append .= '</span>';
+                                       if ( $auto ) {
+                                               $auto = '<span dir="auto"><span class="autocomment">' . $auto . '</span>';
+                                               $append .= '</span>';
+                                       }
+                                       $comment = $pre . $auto;
                                }
                                return $comment;
                        },